<template>
  <div class="classification">
      <div class="title">游戏分类</div>
      <div class="content">
          <div class="btn" :class="{'cur':cur==0}" @click="typeChange(0)">全部游戏</div>
          <div class="btn" v-for="item in data.thirdTypeVos" :key="item.id" :class="{'cur':cur==item.id}" @click="typeChange(item.id)">{{item.name}}</div>
      </div>
  </div>
</template>

<script setup>
import { ref,defineEmits,watch } from "vue";
import { useRoute, useRouter } from "vue-router";

const router = useRouter();
const route = ref(useRoute());
const params = ref(useRoute().params);
const paramsList = params.value.param.split("_");

const props = defineProps({
    data: {
        type: Array,
        default: () => []
    }
});
const emit = defineEmits({
  'typeChange': null,
})
const typeChange=(id)=>{
    emit('typeChange',id)
}
const cur = ref(paramsList[2]||0);
// watch(() => route.value.path,() => {
//   cur.value=route.value.params?.gameType*1||0;
//   let obj={name:'全部游戏',id:0}
//   if(cur.value){
//       for(let i=0;i<props.data.thirdTypeVos.length;i++){
//           if(props.data.thirdTypeVos[i].id===cur.value){
//               obj=props.data.thirdTypeVos[i];
//           }
//       }
//   }
//   emit('typeChange',obj.id)
// },
// {immediate: true}
// )
</script>

<style lang="less" scoped>
.classification {
    width: 100%;
    border-radius: 10px;
    background-color: #fff;
    box-shadow: var(--el-box-shadow-light);
    .title {
        padding-left: 20px;
        height: 50px;
        line-height: 50px;
        border-bottom: 1px solid #eee;
        font-size: 20px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #1d2127;
        line-height: 50px;
    }
    .content {
        .btn {
            margin-left: 16px;
            margin-bottom: 16px;
            display: inline-block;
            width: 90px;
            height: 36px;
            line-height: 36px;
            text-align: center;
            background: #F5F7F8;
            border-radius: 4px;
            font-size: 14px;
            color: #1D2127;
            cursor: pointer;
            &:hover {
                background-color: @theme-color;
                color: #fff;
            }
        }
        .cur {
            background-color: @theme-color;
            color: #fff;
        }
    }
}
</style>
